package com.tpay.server.util;

import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.unitils.core.TestListener;

public class RunBeforeClass extends Statement {
	private static final Logger logger = LoggerFactory.getLogger(RunBeforeClass.class);
	
	private final Statement junitStatement;
	private final Class<?> testClass;
	private final TestListener testListener;
	
	public RunBeforeClass(Statement junitStatement, Class<?> testClass,	TestListener testListener) {
		this.junitStatement = junitStatement;
		this.testClass = testClass;
		this.testListener = testListener;
	}

	@Override
	public void evaluate() throws Throwable {
		this.testListener.beforeTestClass(testClass);
		
		logger.debug("@BeforeClass 실행 전");
		
		this.junitStatement.evaluate();	// @BeforeClass 실행
		
		logger.debug("@BeforeClass 실행 후");
	}
}
